Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore SIGINT and SIGQUIT in non-interactive background processes #6861

Merged
merged 2 commits into from Apr 7, 2020

Conversation

krobelus
Copy link
Member

@krobelus krobelus commented Apr 5, 2020

Fixes #6828

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.md

Copy link
Member

@ridiculousfish ridiculousfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the new test (which is great), in 866d506 I added a fish_test_helper command to print blocked signals, that would be an easy littlecheck test to write.

> status job-control none
> fish_test_helper print_blocked_signals
Interrupt: 2
Quit: 3

src/exec.cpp Outdated
/// Call fork() as part of executing a process \p p in a job \j. Execute \p child_action in the
/// context of the child. Returns true if fork succeeded, false if fork failed.
static bool fork_child_for_process(const std::shared_ptr<job_t> &job, process_t *p,
const dup2_list_t &dup2s, const char *fork_type,
const std::function<void()> &child_action) {
pid_t pid = execute_fork();
if (pid == 0) {
sigset_t sigmask;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's unify signal manipulation under child_setup_process - see the call to signal_reset_handlers. I think you can probably just replace that call outright with one that sets a sigmask, which you compute.

CHANGELOG.md Outdated
@@ -4,6 +4,7 @@
- `fish --no-execute` will no longer complain about unknown commands or non-matching wildcards, as these could be defined differently at runtime (especially for functions). #977
- `jobs --quiet PID` will no longer print 'no suitable job' if the job for PID does not exist (e.g. because it has finished). #6809
- A variable `fish_kill_signal` will be set to the signal that terminated the last foreground job, or `0` if the job exited normally.
- Control-C no longer kills background jobs started in config.fish (#6828).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also say what the underlying change here is, and why (to match POSIX).

@krobelus krobelus force-pushed the background-job-mask-signals branch 2 times, most recently from 04be846 to 7305929 Compare April 7, 2020 19:47
Otherwise it would print "Unknown Signal" on Linux.  I didn't see an
obvious way to check signal validity, plus it hardly matters.

Also mimic the output from BSD strsignal on Linux.
@krobelus krobelus force-pushed the background-job-mask-signals branch from 7305929 to db99c72 Compare April 7, 2020 20:09
@krobelus krobelus added the bug Something that's not working as intended label Apr 7, 2020
@krobelus krobelus added this to the fish 3.2.0 milestone Apr 7, 2020
@krobelus krobelus merged commit 77d33a8 into fish-shell:master Apr 7, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

^C kills the background processes launched at config.fish
2 participants